
package com.xwyzsn.rentcar.controller;
import com.xwyzsn.rentcar.entity.Comment;
import com.xwyzsn.rentcar.service.CommentService;
import com.xwyzsn.rentcar.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;

@RestController()
@RequestMapping(value = "/comment")
@CrossOrigin(value = "*")
public class CommentController {

    @Autowired
    private CommentService service;
    @PostMapping("/get_one")
    public Result getOne(@RequestBody Map<String,?> payload){
        System.out.println(payload);
        return Result.succ(service.getOne(payload));
    }

    @PostMapping("/get_by_userid")
    public Result getByUserId(@RequestBody Map<String,?> payload){
        System.out.println(payload);
        return service.getByUserId(payload);
    }


    @PostMapping("/add_one")
    public Result addOne(@RequestBody Map<String,?>payload){
        return Result.succ(service.addOne(payload));
    }

    @PostMapping("/delete_one")
    public Result deleteOne(@RequestBody Map<String,?>payload){
        return Result.succ( service.deleteOne(payload));
    }

    @PostMapping("/update_one")
    public Integer updateOne(@RequestBody Map<String,?>payload){
        return service.updateOne(payload);
    }
    @GetMapping("/hello")
    public  String hello(){
        return "hello";
    }
}
